'use strict';

const BaseError = exports.BaseError = require('./BaseError');

const ConflictError = exports.ConflictError = require('./ConflictError');

const ForbiddenError = exports.ForbiddenError = require('./ForbiddenError');

const NotFoundError = exports.NotFoundError = require('./NotFoundError');

const UnauthorizedError = exports.UnauthorizedError = require('./UnauthorizedError');

const InternalServerError = exports.InternalServerError = require('./InternalServerError');

const PaymentRequiredError = exports.PaymentRequiredError = require('./PaymentRequiredError');

const BadRequestError = exports.BadRequestError = require('./BadRequestError');

const ServiceUnavailableError = exports.ServiceUnavailableError = require('./ServiceUnavailableError');

const PreconditionFailedError = exports.PreconditionFailedError = require('./PreconditionFailedError');

exports.errors = {
  TokenInvalid: new UnauthorizedError('TokenInvalid', 'Token is invalid.'),
  NoPermission: new ForbiddenError('NoPermission', 'No permission.'),
  Frozen: new ForbiddenError('Frozen', 'Frozen'),
  InvalidUser: new ForbiddenError('InvalidUser', 'User is invalid.'),
  InvalidEmail: new ForbiddenError('InvalidEmail', 'Email is invalid.'),
  FollowYourself: new ForbiddenError('FollowYourself', 'You can\'t follow to yourself.'),
  InvalidParameter: new BadRequestError('InvalidParameter', 'The specified parameter is not valid.'),
  IncompleteTicket: new ForbiddenError('IncompleteTicket', 'Has incomplete tickets.'),
  Paid: new PaymentRequiredError('Paid', 'The order has been paid.'),
  IllegalMoney: new PaymentRequiredError('IllegalMoney', 'The money is illegal.'),
  ThridBindException: new PreconditionFailedError('ThridBindException', 'Three-party binding exception'),
  IllegalContent: new ForbiddenError('IllegalContent', 'Existence of sensitive words.'),
  IllegalImage: new ForbiddenError('IllegalImage', 'Wrong picture format.'),
  InvalidPayment: new PaymentRequiredError('InvalidPayment', 'The payment is invalid.'),
  MissingMatchAccount: new UnauthorizedError('MissingMatchAccount', 'The email or password does not match.'),
  MissingMatchCode: new PreconditionFailedError('MissingMatchCode', 'The code does not match.'),
  NotFoundOpenId: new NotFoundError('NotFoundOpenId', 'OpenId is not found.'),
  NotFoundOrder: new NotFoundError('NotFoundOrder', 'Order is not found.'),
  NotFoundArticle: new NotFoundError('NotFoundArticle', 'Article is not found.'),
  NotFoundTopic: new NotFoundError('NotFoundTopic', 'Topic is not found.'),
  NotFoundActivityId: new NotFoundError('NotFoundActivityId', 'Activity is not found.'),

  NotFoundBinding: new NotFoundError('NotFoundBinding', 'Binding is not found.'),
  ExistsBinding: new ForbiddenError('ExistsBinding', 'Binding already exists.'),
  ExistsEmail: new ForbiddenError('ExistsEmail', 'Email already exists.'),
  ExistsTopic: new BadRequestError('ExistsTopic', 'Topic already exists.'),
  NotFoundCollection: new NotFoundError('NotFoundCollection', 'Collection is not found.'),
  ExistsCollection: new ForbiddenError('ExistsCollection', 'Collection already exists.'),
  NotFoundCommentPraise: new NotFoundError('NotFoundCommentPraise', 'CommentPraise is not found.'),
  ExistsCommentPraise: new ForbiddenError('ExistsCommentPraise', 'CommentPraise already exists.'),
  NotFoundComment: new NotFoundError('NotFoundComment', 'Comment is not found.'),
  NotFoundFollow: new NotFoundError('NotFoundFollow', 'Follow is not found.'),
  NotFoundPraise: new NotFoundError('NotFoundPraise', 'Praise is not found.'),
  NotFoundImageUrl: new NotFoundError('NotFoundImageUrl', 'Image url is not found.'),
  NotFoundImageWidth: new NotFoundError('NotFoundImageWidth', 'Image width is not found.'),
  NotFoundImageHeight: new NotFoundError('NotFoundImageHeight', 'Image height is not found.'),
  ExistsPraise: new ForbiddenError('ExistsPraise', 'Praise already exists.'),
  ExistsFollow: new ForbiddenError('ExistsFollow', 'Follow already exists.'),
  NotFoundMaintenance: new NotFoundError('NotFoundMaintenance', 'Maintenance is not found.'),
  NotFoundMessage: new NotFoundError('NotFoundMessage', 'Message is not found.'),
  NotFoundMovie: new NotFoundError('NotFoundMovie', 'Movie is not found.'),
  NotFoundMoviePraise: new NotFoundError('NotFoundMoviePraise', 'MoviePraise is not found.'),
  ExistsMoviePraise: new ForbiddenError('ExistsMoviePraise', 'MoviePraise already exists.'),
  NotFoundProduct: new NotFoundError('NotFoundProduct', 'Product is not found.'),
  NotFoundSKU: new NotFoundError('NotFoundSKU', 'SKU is not found.'),
  NotFoundSPU: new NotFoundError('NotFoundSPU', 'SPU is not found.'),
  NotFoundUserAccess: new NotFoundError('NotFoundUserAccess', 'UserAccess is not found.'),
  NotFoundUser: new NotFoundError('NotFoundUser', 'User is not found.'),
  NotFoundConfig: new NotFoundError('NotFoundConfig', 'Config is not found.'),
  NotFoundWarranty: new NotFoundError('NotFoundWarranty', 'Warranty is not found.'),
  NotFoundGroup: new NotFoundError('NotFoundGroup', 'Group is not found.'),
  NotFoundSN: new NotFoundError('NotFoundSN', 'SN is not found.'),
  NotFoundSign: new NotFoundError('NotFoundSign', 'Sign is not found.'),
  InvalidPayId: new ForbiddenError('InvalidPayId', 'PayId is invalid'),
  NotFoundModel: new NotFoundError('NotFoundModel', 'Model is not found.'),
  NotFoundTimeStamp: new NotFoundError('NotFoundTimeStamp', 'TimeStamp is not found'),
  NotFoundAppConfig: new NotFoundError('NotFoundAppConfig', 'The appconfig is not found.'),
  NotFoundAuditDesc: new NotFoundError('NotFoundAuditDesc', 'The auditDesc is not found.'),
  NotFoundOperator: new NotFoundError('NotFoundOperator', 'The Operator is not found.'),
  NotFoundError: (code, message) => new NotFoundError(code, message),
  RetWarnException: message => new PreconditionFailedError('RetWarnException', message),
  InvalidAppUUId: new ForbiddenError('InvalidAppUUId', 'AppUUID is invalid'),
  InvalidSN: new ForbiddenError('InvalidSN', 'SN code is invalid.'),
  InvalidUID: new ForbiddenError('InvalidUID', 'UID is invalid.'),
  InvalidArticleID: new ForbiddenError('InvalidArticleID', 'ArticleID is invalid.'),
  InvalidSign: new ForbiddenError('InvalidSign', 'Sign is invalid.'),
  ExpiredRequest: new ForbiddenError('ExpiredRequest', 'User request is expired.'),
  InvalidRepairNumber: new ForbiddenError('InvalidRepairNumber', 'RepairNumber is invalid.'),
  InvalidTarget: new ForbiddenError('InvalidTarget', 'Target is invalid.'),
  InternalError: new InternalServerError('InternalError', 'The request processing has failed due to some unknown error, exception or failure.'),
  ServiceUnavailable: new ServiceUnavailableError('ServiceUnavailable', 'The request has failed due to a temporary failure of the server.'),
  NonEnterpriseUser: new ForbiddenError('NonEnterpriseUser', 'Non-enterprise user'),
  PreconditionFailed: new PreconditionFailedError('PreconditionFailed', 'The preconditions in its headers which the server does not meet.'),
  NotSupportedDevice: new ForbiddenError('NotSupportedDevice', 'This device is not supported'),
};
